package edu.webtech.project.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class ProfilePage extends Composite {

	private static ProfilePageUiBinder uiBinder = GWT
			.create(ProfilePageUiBinder.class);

	interface ProfilePageUiBinder extends UiBinder<Widget, ProfilePage> {
	}

	private MainLayout mainLayout;
	private FileUploadPanel fileUpload = new FileUploadPanel();	
	
	@UiField Button btnUpdateProfile;
	@UiField Button btnUpload;
	@UiField Button btnSearch;
	@UiField Button btnLogout; 
	@UiField SimplePanel tablePanel;
	

	public ProfilePage(MainLayout o) {
		initWidget(uiBinder.createAndBindUi(this));
		mainLayout = o;
		
		tablePanel.add(new SearchPanel());
	}

	@UiHandler("btnUpload")
	void onButtonUpload(ClickEvent e) {
		tablePanel.clear();
		tablePanel.add(fileUpload);
	}
	
	@UiHandler("btnSearch")
	void onButtonSearch(ClickEvent e) {
		tablePanel.clear();
		tablePanel.add(new SearchPanel());
	}
	
	@UiHandler("btnLogout")
	void onBtnLogout(ClickEvent e) {
		mainLayout.getContentPanel().clear();
		mainLayout.getContentPanel().add(new LoginPage(mainLayout));
	}
	
	public SimplePanel getPanel() {
		return tablePanel;
	}
	

}
